import React from 'react'
import { Avatar } from 'antd'
import { fileToUrl } from '@/utils/index'

import './index.scss'
const SetAvatar = ({ avatar, setAvatar }) => {
  return (
    <div className="input-item">
      <label htmlFor="Avatar">头像</label>
      {avatar
        ? <Avatar src={fileToUrl(avatar)} />
        : <input
          onChange={(e) => { setAvatar(e.target.files[ 0 ]) }}
          type="file" />
      }
    </div>
  )
}

export default SetAvatar
